from typing import Optional, List
from pydantic import BaseModel, Field
from datetime import datetime


class BaseSchema(BaseModel):
    class Config:
        allow_population_by_field_name = True
        alias_generator = lambda x: ''.join(word.capitalize() if i else word for i, word in enumerate(x.split('_')))


class SysJobLogBase(BaseSchema):

    job_name: Optional[str] = Field("", alias="jobName")

    job_group: Optional[str] = Field("", alias="jobGroup")

    invoke_target: Optional[str] = Field("", alias="invokeTarget")

    job_message: Optional[str] = Field(None, alias="jobMessage")

    exec_status: Optional[str] = Field(None, alias="execStatus")

    status: Optional[str] = Field(None, alias="status")

    exception_info: Optional[str] = Field(None, alias="exceptionInfo")

    create_by: Optional[str] = Field(None, alias="createBy")

    create_time: Optional[datetime] = Field(None, alias="createTime")

    update_by: Optional[str] = Field(None, alias="updateBy")

    update_time: Optional[datetime] = Field(None, alias="updateTime")

    remark: Optional[str] = Field(None, alias="remark")



class SysJobLogCreate(SysJobLogBase):
    pass


class SysJobLogUpdate(SysJobLogBase):
    pass


class SysJobLogDelete(BaseModel):
    ids: List[int] = Field(..., description="定时任务调度日志表ID列表")


class PageParams(BaseSchema):
    page_num: int = Field(1, ge=1, alias="pageNum", description="页码")
    page_size: int = Field(10, ge=1, le=100, alias="pageSize", description="每页数量")

    job_name: Optional[str] = Field(None, alias="jobName")

    job_group: Optional[str] = Field(None, alias="jobGroup")

    invoke_target: Optional[str] = Field(None, alias="invokeTarget")

    job_message: Optional[str] = Field(None, alias="jobMessage")

    exec_status: Optional[str] = Field(None, alias="execStatus")

    status: Optional[str] = Field(None, alias="status")

    exception_info: Optional[str] = Field(None, alias="exceptionInfo")

    create_by: Optional[str] = Field(None, alias="createBy")

    update_by: Optional[str] = Field(None, alias="updateBy")

    remark: Optional[str] = Field(None, alias="remark")
